Skip to content

fix(js): respect the @nx/js/typescript plugin filters when syncing references - #36484

Draft
FrozenPandaz wants to merge 2 commits into
masterfrom
feature/nxc-4734-typescript-sync-respect-plugin-filters
Draft

fix(js): respect the @nx/js/typescript plugin filters when syncing references#36484
FrozenPandaz wants to merge 2 commits into
masterfrom
feature/nxc-4734-typescript-sync-respect-plugin-filters

Conversation

@FrozenPandaz

Copy link
Copy Markdown
Contributor

Current Behavior

@nx/js:typescript-sync decides which projects belong in the root tsconfig.json references from the project graph alone. It never consults the include/exclude on the @nx/js/typescript plugin's own nx.json registrations, so a project the plugin was explicitly told to skip can still be demanded as a root reference.

This repo already declares that intent:

{
  "plugin": "@nx/js/typescript",
  "exclude": ["examples/angular-rspack/**/*", "examples/react/**/*", "nx-dev/**/*", "e2e/**/*"]
}

Yet adding "composite": true to examples/react/basic/tsconfig.base.json and running nx sync:check reports the workspace out of sync, demanding root references for 13 example projects. Those examples are deliberately standalone pnpm workspaces — own lockfile, own install, link: deps — so referencing them couples the parent repo's tsc --build to a separately installed workspace.

A second, independent bug makes the report misleading. changedFiles, which drives both the out-of-sync verdict and the message, is populated before the composite filter is applied — the filter only runs when deciding what to write. So 12 of those 13 entries were phantom: the angular-rspack examples are not composite and would never have been written. Only examples/react/basic was ever a real candidate.

Expected Behavior

Sync only considers projects the plugin actually manages, and only reports references it could actually write.

Candidates are filtered through findMatchingConfigFiles — the same matcher Nx uses to decide which files a plugin's createNodes sees — so sync and inference agree by construction rather than via two glob implementations that can drift. Matching is against the tsconfig path, since plugin patterns like examples/react/**/* are written against files.

Three behaviors worth calling out:

  • Registrations are additive. This repo has two: the first excludes e2e/**/*, the second includes it. A single-registration read would have dropped every e2e project's reference.
  • It fails open. A bare string registration ("@nx/js/typescript") or no registration at all filters nothing. This is core behavior for every Nx workspace, and narrowing on absent config would be a silent regression.
  • The composite check moved into the first pass, so an unsatisfiable reference is never reported as the reason a workspace is out of sync.

Verification

Two of the five new tests fail without the fix — one per bug. The other three are regression guards proving the filter doesn't over-filter (second registration, bare string, unregistered plugin); those pass either way by design.

End-to-end against this repo, with composite: true added to examples/react/basic:

@nx/js Result
published 23.2.0-beta.2 (no fix) out of sync, 13 missing references
built from this branch no changes, no out-of-sync message

nx run-many -t lint,test -p js passes — 821 tests, including the 43 pre-existing typescript-sync specs.

Note that nx sync:check in this repo runs the published @nx/js, so it cannot exercise this change until release; the A/B above drives the built generator directly against the real workspace.

Related Issue(s)

Fixes NXC-4734


View session information ↗

…ferences

`typescript-sync` picked root `tsconfig.json` references from the project graph
alone, ignoring the `include`/`exclude` on the plugin's own `nx.json`
registrations. Projects the plugin was told to skip were still demanded as root
references — pulling nested standalone workspaces, which have their own lockfile
and install, into the parent repo's TypeScript build graph.

Filters candidates through `findMatchingConfigFiles`, the same matcher Nx uses
to decide which files a plugin's `createNodes` sees, so sync and inference agree
by construction rather than through two glob implementations that can drift.
Registrations are additive, since one may exclude a directory another includes.
It fails open: a bare string registration, or no registration at all, filters
nothing.

Also moves the composite check into the pass that records missing references.
It previously ran only when writing, so a non-composite project could be named
as the reason a workspace was out of sync while being filtered out before any
write — an unsatisfiable message. In nrwl/nx this surfaced as 13 reported
missing references where only 1 was ever a real candidate.

Fixes NXC-4734
@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit e8d4d7f
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a67d56866ca0800087b77d3
😎 Deploy Preview https://deploy-preview-36484--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit e8d4d7f
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a67d5687c144900080586e1
😎 Deploy Preview https://deploy-preview-36484--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 57b5e5c

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 11m 1s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 6s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 54s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 17s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 5s View ↗

☁️ Nx Cloud last updated this comment at 2026-07-27 22:17:41 UTC

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant